import { createBrowserRouter, Navigate } from "react-router-dom";

import Layout from "@/pages/Layout";
import Login from "@/pages/Login";

import AuthRoute from "@/components/AuthRoute";

import Home from "@/pages/Home";
import Publish from "@/pages/Publish";
import Article from "@/pages/Article";
import Error from "@/pages/404";

const router = createBrowserRouter([
    {
        path: "/",
        element:<AuthRoute><Layout /></AuthRoute>,
        children: [
            {
                index: true,
                element: <Home />
            },
            {
                path: "/publish",
                element: <Publish />
            },
            {
                path: "/article",
                element: <Article />
            }
        ]
    },
    {
        path: "/login",
        element: <Login />
    },
    {
        path: "/error",
        element: <Error/>

    },
    {
        path: "*",
        element: <Navigate to="/error" />
    }
])

export default router;